package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class LoginDemo {
    public static void main(String[] args) {
        System.out.println("欢迎登录");
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username=scan.nextLine();
        System.out.println("请输入用户密码：");
        String passWord=scan.nextLine();
        try (
                Connection connection = DBUtil.getConnection();
        ) {
            Statement statement = connection.createStatement();
            String sql = "select username,password from user";
            ResultSet rs = statement.executeQuery(sql);
          /*  while (rs.next()) {
                if ((rs.getString("username").equals(username)) && (rs.getString("password").equals(passWord))) {
                    System.out.println("登陆成功");
                    break;
                } else {
                    System.out.println("不匹配");
                }
            }*/
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
